#include <iostream>
#include <vector>
using namespace std;

//100.00%
class Solution
{
  public:
	void merge(vector<int> &nums1, int m, vector<int> &nums2, int n)
	{
		vector<int> nums;
		int index = 0, i = 0, j = 0;
		while (1)
		{
			if (i < m && j < n)
				nums1[i] < nums2[j] ? nums.push_back(nums1[i++]) : nums.push_back(nums2[j++]);
			else if (i < m && j >= n)
				nums.push_back(nums1[i++]);
			else if (i >= m && j < n)
				nums.push_back(nums2[j++]);
			else
				break;
		}
		for (int k = 0; k < m + n; k++)
		{
			nums1[k] = nums[k];
		}
	}
};

int main()
{
	int nums1[3] = {1, 2, 3};
	int nums2[3] = {2, 5, 6};
	int len1 = sizeof(nums1) / sizeof(int);
	int len2 = sizeof(nums2) / sizeof(int);
	vector<int> myVector1(nums1, nums1 + len1);
	vector<int> myVector2(nums2, nums2 + len2);
	Solution().merge(myVector1, len1, myVector2, len2);
	for (int i = 0; i < len1 + len2 - 1; i++)
	{
		cout << myVector1[i] << " ";
	}
	cout << myVector1[len1 + len2 - 1] << endl;
	return 0;
}
